<?php
class CodeSpace_Oauth_Server_Consumer
{
    private $_key = null;
    
    private $_secret = null;
    
    private $_authentication = null;
    
    public function __construct($key = null, $secret = null)
    {
       if(! is_null($key))
       {
           $this->_key = $key;    
       }     
       
       if(! is_null($secret))
       {
           $this->_secret = $secret;    
       }
    }
    
    /**
     * 
     * Enter description here ...
     * 
     * @return CodeSpace_Oauth_Server_Consumer_Authentication_Database
     */
    public function createDatabaseAuthentication()
    {
        $this->_authentication = new CodeSpace_Oauth_Server_Consumer_Authentication_Database();
        return $this->_authentication;
    }
    
    /**
     * 
     * Enter description here ...
     * 
     * @return CodeSpace_Oauth_Server_Consumer_Authentication_Array
     */
    public function createArrayAuthentication()
    {
        $this->_authentication = new CodeSpace_Oauth_Server_Consumer_Authentication_Array();
        return $this->_authentication;
    }
    
    public function authenticate()
    {
        $result = $this->_authentication->authenticate($this->_key);
       
        if(is_array($result))
        {
            $this->_secret = $result[$this->_key]['secret'];
            return true; 
        }else
        {
            return false;
        }
    }
    
    public function setKey($key)
    {
        $this->_key = $key;
    }
    
    public function getKey()
    {
        return $this->_key;
    }
    
    public function setSecret($secret)
    {
        $this->_secret = $secret;
    }
    public function getSecret()
    {
        return $this->_secret;    
    }
}
?>